<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="en">
<head>
	
	<title>编辑发布信息</title>
	<link rel="stylesheet" href="css/reset.css" />
	<link rel="stylesheet" href="css/public.css" />
	<link rel="stylesheet" href="css/content.css" />
	<script type="text/javascript" src="js/jquery-2.1.1.js"></script>
</head>
<body>

	<div class="container">
		<div class="public-nav">您当前的位置：<a href="">编辑发布信息</a>></div>
		<div class="public-content" style="margin-top: 0">
			<div class="public-content-cont">
			<form action="product_update.action?method=saves" enctype="multipart/form-data" method="post"  style="margin:0 auto;width:50%" onsubmit="return checkForm(this);">
				<s:actionmessage style="font-size:18px;color:#000"/>
				<input type="hidden" id="uuid" value="" name="creatorId"/>
				<div class="form-group">
				<input type="hidden" value="${goods.goodsId }" name="goodsid"/>
					<label for="">请选择分类</label>
					
					<select name="classifyId" class="form-select" style="height: 30px;"id="classify">
						<option>${typename}</option>
						<c:forEach items="${type}" var="p">
						<c:if test="${p.typeName ne typename}">
						
						<option>${p.typeName}</option>
						</c:if>
						</c:forEach>
						
					</select>
				</div>
				
				<div class="form-group">
					<label for="">商品名称</label>
					<input class="form-input-txt" type="text" name="proName" value="${goods.goodsName} " />
				</div>
				<div class="form-group">
					<label for="">商品价格</label>
					<input class="form-input-txt" type="text" name="proPrice" value="${goods.goodsPrice }" />
					
				</div>
				<div class="form-group">
					<label for="">商品描述</label>
					<textarea class="form-input-textara" type="text" name="proDesc" >${goods.goodsDiscrible}</textarea>
				</div>
				
				<div class="form-group">
					<label for="">剩余量</label>
					<input class="form-input-txt" type="text" name="proHassum" value="${goods.goodsNumber}" />
				</div>
				
				<div style="position:absolute;left: 70px;top:20px;"><label>商品图片</label></div>
				
				<div style="position:absolute;left: 70px;top:60px;">
				<img id="preview" style="width:145px;heigth:145px;" src='${pageContext.request.contextPath }/${goods.goodsImg}'/>
				<input type ="hidden" name="proPictureFile" value="${goods.goodsImg}" />
				<br/><input type="file" id="myfile" name="source" onchange="imgPreview(this)"  />
				</div>
				
				
				<div class="form-group" style="position:absolute;left: 70px;top:200px">
					
					
					
					
				</div>
				<div id="large"></div>
				<div class="form-group" style="margin-left:150px;">
					<input type="submit" class="sub-btn" id="btn" value="提  交" />
					<input type="reset" class="sub-btn" value="重  置" />
				</div>
				</form>
			</div>
		</div>
	</div>

</body>

<script type="text/javascript">
	
	
	 function checkForm(form){
	
		 if(form.classifyId.value==""){
			 alert("分类不能为空！");
			 return false;
		}
		
		 
		if(form.proName.value==""){
			alert("类型不能为空！");
			return false;
		}
		
		if(form.proPrice.value==""){
			alert("商品价格不能为空！");
			return false;
		}
		
		
		var re = /^[0-9]+.?[0-9]*$/; 
		if(!re.test(form.proPrice.value)){
			alert("请输入数字");
			return false;
		}
		
		
		if(form.proHassum.value==""){
			alert("剩余量或需求量不能为空！");
			return false;
		}
		
		
		if(!re.test(form.proHassum.value)){
			alert("请输入数字");
			return false;
		}
		
	}	
	
	//加载图片
	function imgPreview(fileDom){
        //判断是否支持FileReader
        if (window.FileReader) {
            var reader = new FileReader();
        } else {
            alert("您的设备不支持图片预览功能，如需该功能请升级您的设备！");
        }

        //获取文件
        var file = fileDom.files[0];
        var imageType = /^image\//;
        //是否是图片
        if (!imageType.test(file.type)) {
            alert("请选择图片！");
            return;
        }
        //读取完成
        reader.onload = function(e) {
            //获取图片dom
            var img = document.getElementById("preview");
            //图片路径设置为读取的图片
            img.src = e.target.result;
        };
        reader.readAsDataURL(file);
    }
	 
</script>
</html>
